package com.ocean.web.controller.system;

import java.util.List;

import com.ocean.system.domain.SysHistoryDaysDo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ocean.common.annotation.Log;
import com.ocean.common.enums.BusinessType;
import com.ocean.system.service.ISysHistoryDaysService;
import com.ocean.common.core.controller.BaseController;
import com.ocean.common.core.domain.AjaxResult;
import com.ocean.common.core.page.TableDataInfo;

/**
 * @Author: FuGui Wang
 * @Description: 未更新产品天数维护Controller
 * @Date 2023/2/17
 * @Version V1.1.0
 */
@Controller
@RequestMapping("/system/days")
public class SysHistoryDaysController extends BaseController
{
    private String prefix = "system/days";

    @Autowired
    private ISysHistoryDaysService sysHistoryDaysService;

    @RequiresPermissions("system:days:view")
    @GetMapping()
    public String days()
    {
        return prefix + "/days";
    }

    /**
     * 查询未更新产品天数维护列表
     */
    @RequiresPermissions("system:days:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysHistoryDaysDo sysHistoryDaysDo)
    {
        startPage();
        List<SysHistoryDaysDo> list = sysHistoryDaysService.selectSysHistoryDaysList(sysHistoryDaysDo);
        return getDataTable(list);
    }

    /**
     * 新增未更新产品天数维护
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存未更新产品天数维护
     */
    @RequiresPermissions("system:days:add")
    @Log(title = "未更新产品天数维护", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysHistoryDaysDo sysHistoryDaysDo)
    {
        return toAjax(sysHistoryDaysService.insertSysHistoryDays(sysHistoryDaysDo));
    }

    /**
     * 修改未更新产品天数维护
     */
    @RequiresPermissions("system:days:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        SysHistoryDaysDo sysHistoryDaysDo = sysHistoryDaysService.selectSysHistoryDaysById(id);
        mmap.put("sysHistoryDaysDo", sysHistoryDaysDo);
        return prefix + "/edit";
    }

    /**
     * 修改保存未更新产品天数维护
     */
    @RequiresPermissions("system:days:edit")
    @Log(title = "未更新产品天数维护", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysHistoryDaysDo sysHistoryDaysDo)
    {
        return toAjax(sysHistoryDaysService.updateSysHistoryDays(sysHistoryDaysDo));
    }

    /**
     * 删除未更新产品天数维护
     */
    @RequiresPermissions("system:days:remove")
    @Log(title = "未更新产品天数维护", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysHistoryDaysService.deleteSysHistoryDaysByIds(ids));
    }
}
